<?php
header("Content-type: text/html; charset=utf-8"); 

class ConnData{
	var $conn;
	public function __construct(){
		include 'change_database.php';
    	$this->conn = new mysqli($db_servername, $db_username, $db_password,$db_database);

		
		if(mysqli_connect_errno()){
    		echo "连接数据库失败：".mysqli_connect_error();
    		$this->conn=null;
    		exit;
    	}

	}
	public function __destruct() {
		$this->conn->close();
    }
}

function uidToUsername($uid){
	$link=new ConnData();
	$sql="select username from userdata where uid=".$uid;	
		$result = mysqli_query($link->conn,$sql);
		if($result === false){
    		echo $link->conn->error;
    		echo $link->conn->errno;
		}
		$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
		$username=$_GET['uid'];
		return $username;
}

?>